//统一管理咱们项目用户相关的接口
import request from "@/utils/request";
import type {
    HandleResponseData, UuidForm
} from "../../common/type";

import {
    AllColListResponseData,
    TableConfigAddOrUpdateForm,
    TableConfigListResponseData,
    TableConfigResponseData
} from "@/api/sys/tableConfig/type";
//项目用户相关的请求地址
enum API {
    //用户列表
    pageListUrl = "/bg/tableConfig/pageList",
    //编辑
    updateUrl = "/bg/tableConfig/update",
    //详情
    infoUrl = "/bg/tableConfig/detail",
    //生成代码
    genCode = "/bg/tableConfig/genCode",

    allListCol = "/bg/columnInfo/allListByTableUuid",
}

//编辑
export const reqUpdateTableConfig = (tableConfigAddOrUpdateForm: TableConfigAddOrUpdateForm) => request.post<any, HandleResponseData>(API.updateUrl,tableConfigAddOrUpdateForm)

//生成代码
export const reqTableGenCode = (uuidForm: UuidForm) => request.post<any, HandleResponseData>(API.genCode,uuidForm);


//分页列表
export const reqTableConfigList = (page: number, pageSize: number,tableNameLike: string ,databaseNameLike:string,dataSourceNameLike :string) =>
    request.get<any, TableConfigListResponseData>(API.pageListUrl+`?tableNameLike=${tableNameLike}&page=${page}
    &pageSize=${pageSize}&databaseNameLike=${databaseNameLike}&dataSourceNameLike=${dataSourceNameLike}`)

//详情
export const reqConfigInfo = (tableUuid:string) => request.get<any, TableConfigResponseData>(API.infoUrl+`?tableUuid=${tableUuid}`)

export const reqAllListCol = (tableUuid:string) => request.get<any, AllColListResponseData>(API.allListCol+`?tableUuid=${tableUuid}`)



